﻿using System;
using System.Text;
using Notepad_X.Classes;

namespace Notepad_X
{
     /// <summary>
     /// Notepad_X.API Class
     /// </summary>
     /// <param name="_main">Instance of Main form class</param>
    public class API
    {
        public static Main main = Notepad_X.Static.MainInstance;

        /// <summary>
        /// Creates new API Class
        /// </summary>
        /// <param name="_main">Instance of Main form class</param>
        public API(Main _main)
        {
            main = _main;
        }
        public API()
        {
            //main = Notepad_X.Static.MainInstance;
        }

        /// <summary>
        /// Assign the Notepad_X.Main class
        /// </summary>
        /// <param name="_main">Instance of Main form class</param>
        public static void set(Main _main)
        {
            main = _main;
        }
        
        /// <summary>
        /// Returns a ToolStripMenuItem from the main menu with the selected name
        /// </summary>
        /// <param name="name">Control name of the ToolStripMenuItem item</param>
        public static System.Windows.Forms.ToolStripMenuItem get_MenuItem(string name){
            return main.system_menuItem_Get(name);
        }

        public static class Documents
        {
            /// <summary>
            /// Returns the Documents ArrayList collection
            /// </summary>
            //public static System.Collections.Generic.List<Documents> getArray()
            //{
            //    return main.Documents;
            //}
            /// <summary>
            /// Returns the Notepad_X.Document[] collection of specific id
            /// </summary>
            /// <param name="id">Item position in Document[] collection</param>
            public static Notepad_X.Document getDocument(int id)
            {
                return (Document)main.Documents[id];
            }

            /// <summary>
            /// Returns the Notepad_X.Document count in Notepad_X.Document[] collection
            /// </summary>
            public static int count()
            {
                return main.Documents.Count;
            }
            /// <summary>
            /// Create new document
            /// </summary>
            public static void New()
            {
                main.handler_new(null, null);
            }
            /// <summary>
            /// Close the current document
            /// </summary>
            public static void Close()
            {
                main.handler_close(null, null);
            }
            /// <summary>
            /// Opens an file
            /// </summary>
            public static void Open()
            {
                main.handler_open(null, null);
            }

            /// <summary>
            /// Opens an specific file
            /// </summary>
            /// <param name="Filename">Path of the file (make sure its exists)</param>
            public static void Open(String Filename)
            {
                main.system_open(Filename);
            }

            /// <summary>
            /// Save the current document
            /// </summary>
            public static void Save()
            {
                main.handler_save(null, null);
            }
            /// <summary>
            /// Save As the current document
            /// </summary>
            public static void SaveAs()
            {
                main.handler_saveAs(null, null);
            }
            /// <summary>
            /// Print the current document
            /// </summary
            public static void Print()
            {
                main.handler_print(null, null);
            }
            /// <summary>
            /// Selected Document
            ///
            /// </summary
            //public static class SelectedDocument
            //{
            //    /// <summary>
            //    /// Returns the selected Document as Notepad_X.Document object in case of there is no selected it will return null
            //    /// </summary
            //    public static Notepad_X.Document get()
            //    {
            //        int id = main.get_selectedID();
            //        if (id != -1)
            //        {
            //            return main.Documents[id];
            //        }
            //        return null;
            //    }
            //    /// <summary>
            //    /// Returns the selected text of the selected Document as string in case of there is no selected it will return null
            //    /// </summary
            //    public static string getSelectedText()
            //    {
            //        int id = main.get_selectedID();
            //        if (id != -1)
            //        {
            //            return main.Documents[id].text_box.ActiveTextAreaControl.SelectionManager.SelectedText;
            //        }
            //        return null;
            //    }
            //}
        }
    } 
}
